/***************************************************************************************************
 *Copyright(C),2010-2016,Sumscope
 *FileName	:  DictTableCreator.cpp
 *Author	:  scofined.qi
 *Version	:  1.0
 *Date		:  2017/04/05
 *Desc		:  //用于主要说明此程序文件完成的主要功能
 *Relation :
 *Others	:  //其他内容说明
 *Function :  //主要函数列表，每条记录应包含函数名及功能简要说明
 *History	:
 * //修改历史记录列表，每条修改记录应包含修改日期、修改者及修改内容简介
 ***************************************************************************************************/
#include <core/FileSys.h>
#include <core/strings/base64.h>
#include <core/strings/string_util.h>

#include "DictManager.h"
#include "DictTable.h"
#include "DictType.h"
#include "KeyFieldMaker.h"

#ifdef USING_CONFIGVM
#include "../SSTools/ConfigVM.h"
#endif

#ifdef WIN32
#else
#define _TRUNCATE ((size_t)-1)
#define FIELD_OFFSET(type, field) ((long)(long)&(((type*)0)->field))
#define RTL_FIELD_SIZE(type, field) (sizeof(((type*)0)->field))
#endif

#ifndef BLOGDEBUG
#define BLOGDEBUG  //
#endif
#ifndef BLOGERR
#define BLOGERR  //
#endif
#ifndef BLOGINFO
#define BLOGINFO  //
#endif
#ifndef BLOGCRIT
#define BLOGCRIT  //
#endif
#ifndef MEM_METRIC
#define MEM_METRIC  //
#endif
#ifndef BVIEW
#define BVIEW  //
#endif
#ifndef BS_CFGMETRICS
#define BS_CFGMETRICS  //
#endif
#ifndef BS_METRICS
#define BS_METRICS  //
#endif
#ifndef LOGWARN
#define LOGWARN  //
#endif
#ifndef LOGDEBUG
#define LOGDEBUG  //
#endif
#ifndef BLOGWARN
#define BLOGWARN  //
#endif
#ifndef LOGERR
#define LOGERR  //
#endif
#ifndef LOGINFO
#define LOGINFO  //
#endif
#ifndef LOGEMERG
#define LOGEMERG  //
#endif

/*
        此文件用于一次性初始化字典所需要的表格的描述信息,如列名称偏移量大小类型等等
        如果对应字段改变,那么这里需要相应做出调整,否则运行时检查会失败
        后续改进:
                在ADDFIELD宏中增加静态检查
*/

typedef qb::base::strinfo strinfo;
typedef qb::base::StringUtil StringUtil;

namespace qb {
namespace ht {

/*
辅助的注记宏
*/
#define ADDFIELD(OBJ, TYPE, FIELD, DESC)                             \
  pdd->AddField(FieldDesc((kDataType)TYPE, FIELD_OFFSET(OBJ, FIELD), \
                          RTL_FIELD_SIZE(OBJ, FIELD), #FIELD, DESC))
#define ADDKEYFIELD(OBJ, TYPE, FIELD, DESC)                             \
  pdd->AddKeyField(FieldDesc((kDataType)TYPE, FIELD_OFFSET(OBJ, FIELD), \
                             RTL_FIELD_SIZE(OBJ, FIELD), #FIELD, DESC))
#define CHECK_ADD_DICTDESC(PDD) \
  PDD->CheckValid();            \
  PDD++;

static char gs_dict_debugkey[128] = {0};
const char* DictDesc::GetDebugKey() {
  return gs_dict_debugkey[0] == 0 ? 0 : gs_dict_debugkey;
}
void DictDesc::SetViewSize(int viewSize, int increaseSize) {
  // viewsize:1-16
  // increaseSize:1-32
  viewSize = viewSize < 1 ? 1 : (viewSize > 16 ? 16 : viewSize);
  increaseSize = increaseSize < viewSize
                     ? viewSize
                     : (increaseSize > 32 ? 32 : increaseSize);
  increaseSize = ROUND_ALIGN(increaseSize, viewSize);
  m_view_size = viewSize;
  m_increase_size = increaseSize;
}
void DictDesc::SetDebugKey(const char* key) {
  memset(gs_dict_debugkey, 0, _countof(gs_dict_debugkey));
  if (key) {
    strncpy(gs_dict_debugkey, key, _TRUNCATE);
    BLOGINFO("DictDebugKey:%s", key);
  }
}
void DictDesc::SetExportFields(const char* fields) {
  // 以逗号分割的字段名称
  BASSERT(fields);
  strinfo tokens[256] = {0};
  int num =
      StringUtil::SplitStringInfo(fields, strlen(fields), ",", tokens, 256);
  for (int i = 0; i < num; i++) {
    const char* name = fields + tokens[i].pos;
    int index = FindColumn(name, tokens[i].len);
    if (index < 0) {
      BLOGERR("[DICT][FIELD]%s invalid export field:%s", m_name.c_str(), name);
    } else
      m_export_indexes.push_back(index);
  }
}
void DictDesc::SetTag(const std::string& tag) {
  if (tag.empty()) {
    m_tag_name = tag;
    return;
  }
  qb::base::BaseString in = tag.c_str(), out;
  qb::base::Base64::Encode(in, out);
  m_tag_name = out.c_str();
}
void SetDictParams(DictDesc* dds, int ncount, const char* params) {
  /*
          格式:
                  单行文本
                  每个分组之间用;分割开
                  每个分组内部以,隔开,有3个元素,第一个是DictDesc的name,第二个是viewsize,第三个是increasesize
                  viewsize/increasesize为0或者-等不是数字,表示使用默认值
                  其中要求increasesize必须比viewsize大
                  且都有取值范围
          示例:
                  BondList.fmap,4,8;BondPrimaryInfo.fmap,4,8;BondAdditionInfo.fmap,4,8;BondDict.fmap,4,8;
  */
  int len = params == 0 ? 0 : (strlen(params));
  if (len <= 0) return;

  strinfo tokens[256];
  int tknum = StringUtil::SplitStringInfo(params, len, ";,", tokens, 256);
  for (int i = 0; i < tknum; i += 3) {
    std::string name = std::string(params + tokens[i].pos, tokens[i].len);
    int select = -1;
    for (int k = 0; k < ncount && select < 0; k++)
      if (dds[k].GetName() == name) select = k;
    if (select < 0) {
      BLOGERR("invalid kProfileDictParams token:%s index:%d expect in DictDesc",
              name.c_str(), i);
      continue;
    }
    int view = atoi(params + tokens[i + 1].pos);
    int increase = atoi(params + tokens[i + 2].pos);
    dds[select].SetViewSize(view, increase);
    BLOGINFO("Update Dict Params[%d]:%s view:%d %d increase:%d %d", i,
             name.c_str(), view, dds[select].GetViewSize(), increase,
             dds[select].GetIncreaseSize());
  }
}
const DictDesc& DictDesc::GetStockDictDesc(int index) {
  /*
  这些对象常驻内存,用于描述字典数据表的信息,如名称,列信息等等
  QBBondListV17	-->	QBBondListV18
  QBBondPrimaryInfoV3	-->	QBBondPrimaryInfoV5 --> QBBondPrimaryInfoV6
  QBBondAdditionInfoV2	-->	QBBondAdditionInfoV3
  BondDictV19	-->	BondDictV20
  Holiday	-->	HolidayV3
  MacroIndex	-->	不校验，不做升级
  QBIssuerInfoV3	-->	QBIssuerInfoV6
  QBProvinceInfo	-->	QBProvinceInfoV2
  QBSwSectorInfo	-->	QBSwSectorInfoV2
  QBSwSectorInfo2021
  UnderwriterV2	-->	UnderwriterV3
  FinancialCompanyV1	-->	已经包含Sequence号，无需升级
  ContinuousContractInfoV1	-->	ContinuousContractInfoV2
  ExchangeRepoV1	-->	ExchangeRepoV2

  */
  static bool initialized = false;
  static DictDesc dds[kDictTypeCount] = {
      DictDesc("BondList.fmap", "QBBondListV5433", "BOND_LIST",
               sizeof(BOND_LIST), "ComBondKey", "Flag"),
      DictDesc("BondPrimaryInfo.fmap", "QBBondPrimaryInfoV5433",
               "BOND_PRIMARY_INFO", sizeof(BOND_PRIMARY_INFO), "ComBondKey",
               "Flag"),
      DictDesc("BondAdditionInfo.fmap", "QBBondAdditionInfoV5433",
               "BOND_ADDITION_INFO", sizeof(BOND_ADDITION_INFO),
               "Add_Issue_Key", "Flag"),
      DictDesc("BondOptionInfo.fmap", "QBBondOptionInfoV5433",
               "BOND_OPTION_INFO", sizeof(BOND_OPTION_INFO), "ComBondKey",
               "Flag"),
      DictDesc("BondAuctionInfo.fmap", "BondAuctionInfoV5433",
               "BOND_AUCTION_INFO", sizeof(BOND_AUCTION_INFO), "Bond_Key",
               "Flag"),
      DictDesc("BondDict.fmap", "BondDictV22", "BOND_DICT", sizeof(BOND_DICT),
               "Key", "Flag", new BondDictKeyMaker()),
      DictDesc("Holiday.fmap", "HolidayV3", "BOND_HOLIDAY",
               sizeof(BOND_HOLIDAY), "Key", "Flag", new BondHolidayKeyMaker()),
      DictDesc("MacroIndex.fmap", "MacroIndex", "MACRO_INDEX",
               sizeof(DICT_MACRO_INDEX), "Key", "Flag",
               new MacroIndexKeyMaker()),
      DictDesc("IssuerInfo.fmap", "QBIssuerInfoV7", "QB_ISSUERINFO",
               sizeof(QB_ISSUERINFO), "Institution_Code", "Flag"),
      DictDesc("ProvinceInfo.fmap", "QBProvinceInfoV3", "QB_PROVINCEINFO",
               sizeof(QB_PROVINCEINFO), "Area_Code", "Flag"),
      DictDesc("SwSectorInfo.fmap", "QBSwSectorInfoV2", "QB_SWSECTORINFO",
               sizeof(QB_SWSECTORINFO), "SW_Internal_Code", "Flag"),
      DictDesc("SwSectorInfo2021.fmap", "QBSwSectorInfo2021", "QB_SWSECTORINFO",
               sizeof(QB_SWSECTORINFO), "SW_Internal_Code", "Flag"),
      DictDesc("Underwriter.fmap", "UnderwriterV3", "QB_UNDERWRITER",
               sizeof(QB_UNDERWRITER), "UnderwriterCode", "Flag"),
      DictDesc("SSData0.fmap", "FinancialCompanyV1", "QB_FINANCIAL_COMPANY",
               sizeof(QB_FINANCIAL_COMPANY), "CompanyID", "Flag"),
      DictDesc("ContinCInfo.fmap", "ContinuousContractInfoV3",
               "QB_CONTINUOUS_CONTRACT_INFO",
               sizeof(QB_CONTINUOUS_CONTRACT_INFO), "ID", "Flag"),
      DictDesc("ExchangeRepo.fmap", "ExchangeRepoV2", "QB_EXCHANGEREPO_INFO",
               sizeof(QB_EXCHANGEREPO_INFO), "ID", "Flag"),
      DictDesc("BondCDCAuth.fmap", "BondCDCAuthV5433", "QB_BONDCDCAUTH",
               sizeof(QB_BONDCDCAUTH), "BondKey", "Flag"),
      DictDesc("BondCrmClause.fmap", "BondCrmClauseV5433", "QB_BONDCRM",
               sizeof(QB_BONDCRM), "Bond_Key", "Flag"),
      DictDesc("ABSBond.fmap", "ABSBondV5433", "QB_ABSBOND", sizeof(QB_ABSBOND),
               "Bond_Key", "Flag"),
      DictDesc("MainUnderWriter.fmap", "MainUnderwriterV2",
               "QB_MAIN_UNDERWRITER", sizeof(QB_MAIN_UNDERWRITER),
               "Institution_Code", "Flag"),
      DictDesc("BondConversion.fmap", "BondConversionV5433", "BOND_CONVERSION",
               sizeof(BOND_CONVERSION), "ComBondKey", "Flag"),
      DictDesc("BondDefaulted.fmap", "BondDefaultedV1", "BOND_DEFAULTED",
               sizeof(BOND_DEFAULTED), "ComBondKey", "Flag"),
      DictDesc("BondKongfu.fmap", "SkyKongfuBondInfoV1", "BOND_KONGFU",
               sizeof(BOND_KONGFU), "ISIN_Code", "Flag"),
      DictDesc("SpecialLabelInfo.fmap", "SpecialLabelInfoV2",
               "SPECAIL_LABEL_INFO", sizeof(SPECAIL_LABEL_INFO), "id", "Flag"),
      DictDesc("BondSpecialLabel.fmap", "BondSpecialLabelV5433",
               "BOND_SPECIAL_LABEL", sizeof(BOND_SPECIAL_LABEL), "bond_label",
               "Flag"),
  };
  BASSERT(index >= kDictTypeBondList && index < kDictTypeCount);
  if (initialized) {
    return dds[index];
  }
#ifdef USING_CONFIGVM
  SetDebugKey(AfxGetConfig().GetString(kProfileDictDebugKey));
#endif
  for (int i = 0; i < kDictTypeCount; i++) dds[i].SetType((kDictType)i);

  // 实际上就是旧cod字典文件大小,以kb为单位
  const int predictsize[] = {54670, 25834, 862, 32, 32,    62, 44, 4640, 1272,
                             130,   6,     2,   2,  14614, 15, 1,  5897, 28,
                             50,    1,     1,   1,  1,     1,  1};
  static_assert(_countof(predictsize) == kDictTypeCount,
                "predictsize must equal to kDictTypeCount");
  for (int i = 0; i < kDictTypeCount; i++)
    dds[i].SetPredictSize(predictsize[i] * 1024);

  QString path = FileSys::instance()->dataDir() + "/BondData/";
  FileSys::instance()->makePathExist(path);
  DictDesc* pdd = dds + kDictTypeBondList;
  // kDictTypeBondList
  ADDFIELD(BOND_LIST, kDataTypeCharArray, ComBondKey, "债券组合键");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, BondID, "债券代码 1280197");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, ShortName, "债券简称 12北京建工债");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, BondSubType,
           "债券类型 LEB/LMN/LCP...");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Guarantee, "担保类型");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, TermToMaturity, "剩余期限");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, ListDate, "上市日期");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, MaturityDate, "到期日");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, OptionDate, "行权日期");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, IssuerRating, "主体评级，发行人评级");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, BondRating, "债项评级");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, InstitutionRating,
           "主体评级，含AAA+");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, RateType, "评级类型 FIXED");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Coupon_Type, "利率方式");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, MarketType, "市场类型");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, InterestStartDate, "起息日");
  ADDFIELD(BOND_LIST, kDataTypeChar, IsMortgate, "是否质押");
  ADDFIELD(BOND_LIST, kDataTypeChar, IsCrossMarket, "是否跨市场");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, InstitutionSubtype,
           "机构类型 LGE/PVE...");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, YieldCurveType, "收益率曲线标识");
  ADDFIELD(BOND_LIST, kDataTypeChar, IsMunicipal, "是否城投债 Y/N/NULL");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, BondFullName, "债券全称");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, MaturityTerm, "债券期限");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, OptionType, "期权类型");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Issuer_Code, "发行人代码");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, FullNameEN, "英文全称");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, ShortNameEN, "英文简称");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Outlook, "展望		V11");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Ent_Cor, "公司债	V11");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Coupon_Frequency, "付息频率 V15");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Compound_Frequency, "计息频率 V15");
  ADDFIELD(BOND_LIST, kDataTypeInt, No_Add_Issue, "第几次增续发 V15");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Planned_Exercise_Date,
           "下一行权日 20160102");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Next_Coupon_Date,
           "下一付息日 20160102");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Issue_Rate,
           "发行收益率，参考收益率 2.6246");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, FRN_Index_ID, "基准利率代码");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Fixing_MA_Days,
           "基准利率计算周期（平均）");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Issuer_Rating_Institution_Code,
           "发行人评级机构代码");
  ADDFIELD(BOND_LIST, kDataTypeDouble, Outstanding_Amount, "债券余额");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Interest_Basis, "利息基础");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, IssuerRatingCBR, "中债资信评级");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, OutlookCBR, "中债资信评级状态");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, CDC_Implied_Rating, "中债隐含评级");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, CSI_Implied_Rating, "中证隐含评级");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Currency, "货币种类");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Warranter, "担保人");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, bond_tag, "标签");
  ADDFIELD(BOND_LIST, kDataTypeInt, pay_date, "实际兑付日");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Sceniority, "次级债字段");
  ADDFIELD(BOND_LIST, kDataTypeCharArray, Category_flag, "专项债类型");
  ADDFIELD(BOND_LIST, kDataTypeChar, Flag, "不写入文件,D:删除 U:更新 I:插入");
  ADDFIELD(BOND_LIST, kDataTypeInt, Sequence, "变更序列号");
  ADDKEYFIELD(BOND_LIST, kDataTypeCharArray, Key.BondKey,
              "债券key B0000332012CORLEB01");
  ADDKEYFIELD(BOND_LIST, kDataTypeCharArray, Key.ListedMarket,
              "市场代码 CIB/SSE/SZE");

  // kDictTypeBondPrimaryInfo
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, ComBondKey, "债券组合键");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeDouble, PlannedIssueAmount,
           "预期发行量");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeDouble, Actual_Issue_Amount,
           "实际发行量");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, PaymentDate, "缴款日");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, CouponRateCurrent,
           "中标价格");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, AuctionDateStart,
           "招标建档起始日");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, AuctionDateEnd,
           "招标建档截止日");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Auction_Date_Time,
           "公告日期");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, AnnounceDate, "公告日期	");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, IssueStartDate, "发行起始日");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, IssueEndDate, "发行截止日");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Issue_End_Time,
           "发行截止时间");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Issue_Period, "募集周期");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Underwriters,
           "承销商，逗号分隔");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Bid_Limit_Bottom,
           "投标区间下限");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Bid_Limit_Top,
           "投标区间上限");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Auction_Flr, "标位下限");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Auction_Cap, "标位上限");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Auction_Step, "步长");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Auction_Unit, "标位单位");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, MainUnderwriters, "主承销商");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, JointUnderwriters,
           "联席承销商");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeInt, BondFileNum, "可下载文件数量");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Auction_Type, "发行方式");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeInt, Auction_Time_Start, "发行开始时间");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeInt, Auction_Time_End, "发行结束时间");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Issue_Type, "招标方式");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Asset_Status, "资产类型");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeChar, Flag,
           "不写入文件,D:删除 U:更新 I:插入");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeInt, Sequence, "变更序列号");
  ADDFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Type, "偿还方式");
  ADDKEYFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Key.BondKey,
              "债券key B0000332012CORLEB01");
  ADDKEYFIELD(BOND_PRIMARY_INFO, kDataTypeCharArray, Key.ListedMarket,
              "市场代码 CIB/SSE/SZE");

  // kDictTypeBondAdditionInfo
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeInt, No_Add_Issue, "第几次增续发");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, First_Issue_Key,
           "原券Bondkey");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Issue_Key,
           "增续发券BondKey");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Full_Name,
           "增续发券全称");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Announce_Date,
           "增续发公告日期");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Auction_Date,
           "增续发招标建档日");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Issue_Start_Date,
           "增续发发行起始日");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Issue_End_Date,
           "增续发发行结束日");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Dist_Date_Start,
           "增续发分销开始日");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Dist_Date_End,
           "增续发分销结束日");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Payment_Date,
           "增续发承销缴款日");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Listed_Date,
           "增续发上市日");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeDouble, Add_Issue_Commission_Rate,
           "增/续发手续费率(%)");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeDouble, Add_Issue_Price,
           "增/续标售价格(元)");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeDouble, Add_Planned_Issue_Amount,
           "计划增/续发总额(万元)");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeDouble, Add_Issue_Amount,
           "实际增/续发总额(万元)");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Reason, "增续发原因");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Issue_ID,
           "增/续发债券代码");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Add_Issue_Short_Name,
           "增续发券简称");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, First_Issue_ID, "原券代码");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Mkt_Type, "市场类型");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Ann_Status, "流通要素状态");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Bid_Outcome,
           "发行收益率，参考收益率 2.6246");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeCharArray, Auction_Type, "发行方式");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeInt, Auction_Time_Start,
           "发行开始时间");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeInt, Auction_Time_End, "发行结束时间");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeInt, Sequence, "变更序列号");
  ADDFIELD(BOND_ADDITION_INFO, kDataTypeChar, Flag, "");

  // kDictTypeBondOptionInfo
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(BOND_OPTION_INFO, kDataTypeCharArray, ComBondKey, "债券组合键");
  ADDFIELD(BOND_OPTION_INFO, kDataTypeCharArray, CallStr, "赎回行权日期");
  ADDFIELD(BOND_OPTION_INFO, kDataTypeCharArray, PutStr, "回售行权日期");
  ADDFIELD(BOND_OPTION_INFO, kDataTypeCharArray, OptionType, "含权类型");
  ADDFIELD(BOND_OPTION_INFO, kDataTypeChar, Flag, "");
  ADDFIELD(BOND_OPTION_INFO, kDataTypeInt, Sequence, "变更序列号");
  ADDKEYFIELD(BOND_OPTION_INFO, kDataTypeCharArray, Key.BondKey,
              "债券key B0000332012CORLEB01");
  ADDKEYFIELD(BOND_OPTION_INFO, kDataTypeCharArray, Key.ListedMarket,
              "市场代码 CIB/SSE/SZE");

  // kDictTypeBondAuctionInfo
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(BOND_AUCTION_INFO, kDataTypeCharArray, Bond_Key, "BondKey");
  ADDFIELD(BOND_AUCTION_INFO, kDataTypeInt, Auction_Time_Start, "招标时间起");
  ADDFIELD(BOND_AUCTION_INFO, kDataTypeInt, Auction_Time_End, "招标时间止");
  ADDFIELD(BOND_AUCTION_INFO, kDataTypeDouble, Planed_Auction_Amount,
           "计划发行量");
  ADDFIELD(BOND_AUCTION_INFO, kDataTypeDouble, Actual_Auction_Amount,
           "实际发行量");
  ADDFIELD(BOND_AUCTION_INFO, kDataTypeDouble, WA_Tender_Rate, "加权利率");
  ADDFIELD(BOND_AUCTION_INFO, kDataTypeDouble, MG_Tender_Rate, "边际利率");
  ADDFIELD(BOND_AUCTION_INFO, kDataTypeDouble, Subscription_Ratio, "全场倍数");
  ADDFIELD(BOND_AUCTION_INFO, kDataTypeDouble, Marginal_Ratio, "边际倍数");
  ADDFIELD(BOND_AUCTION_INFO, kDataTypeChar, Flag, "");
  ADDFIELD(BOND_AUCTION_INFO, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeBondDict
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(BOND_DICT, kDataTypeCharArray, Key, "");
  ADDFIELD(BOND_DICT, kDataTypeCharArray, Selective_Code, "");
  ADDFIELD(BOND_DICT, kDataTypeCharArray, Selective_Content, "");
  ADDFIELD(BOND_DICT, kDataTypeCharArray, Selective_Content_EN, "");
  ADDFIELD(BOND_DICT, kDataTypeCharArray, SortCode, "");
  ADDFIELD(BOND_DICT, kDataTypeCharArray, Group_Name, "");
  ADDFIELD(BOND_DICT, kDataTypeCharArray, Group_Name_Original, "");
  ADDFIELD(BOND_DICT, kDataTypeCharArray, Selective_Code_Original, "");
  ADDFIELD(BOND_DICT, kDataTypeChar, Flag, "");
  ADDFIELD(BOND_DICT, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeBondHoliday
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(BOND_HOLIDAY, kDataTypeCharArray, Key, "");
  ADDFIELD(BOND_HOLIDAY, kDataTypeCharArray, Country, "");
  ADDFIELD(BOND_HOLIDAY, kDataTypeCharArray, Market, "");
  ADDFIELD(BOND_HOLIDAY, kDataTypeInt, Holiday, "");
  ADDFIELD(BOND_HOLIDAY, kDataTypeCharArray, Status, "");
  ADDFIELD(BOND_HOLIDAY, kDataTypeChar, Flag, "");
  ADDFIELD(BOND_HOLIDAY, kDataTypeCharArray, HolidayReason, "放假原因");
  ADDFIELD(BOND_HOLIDAY, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeMacroIndex
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(DICT_MACRO_INDEX, kDataTypeCharArray, Key, "");
  ADDFIELD(DICT_MACRO_INDEX, kDataTypeCharArray, Code, "");
  ADDFIELD(DICT_MACRO_INDEX, kDataTypeDouble, Value, "");
  ADDFIELD(DICT_MACRO_INDEX, kDataTypeInt, Date, "");
  ADDFIELD(DICT_MACRO_INDEX, kDataTypeInt, EndDate, "");
  ADDFIELD(DICT_MACRO_INDEX, kDataTypeInt, Sequence, "变更序列号");
  ADDFIELD(DICT_MACRO_INDEX, kDataTypeChar, Flag, "");

  // kDictTypeIssuerInfo
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Institution_Code, "发行人代码");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Full_Name_C, "发行机构全称");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Issuer_Type, "机构类型");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, SW_Sector_Code, "一级行业代码");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, SW_Subsector_Code,
           "二级行业代码");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, SW_Sector_Code_2021,
           "2021版申万行业代码");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Province_Code, "区域代码");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Short_Name_C, "中文简称");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Full_Name_E, "英文全称");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Short_Name_E, "英文简称");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Listed_Type, "上市公司");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Actual_Controller_Name,
           "实际控制人");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Actual_Controller_Type,
           "实际控制人类型");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Rate, "评级");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, CBRC_Financing_Platform,
           "银监会投融资平台，Y = 平台债");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Municipal_code, "城市代码");
  ADDFIELD(QB_ISSUERINFO, kDataTypeCharArray, Issuer_tag, "主体信息");
  ADDFIELD(QB_ISSUERINFO, kDataTypeChar, Flag, "");
  ADDFIELD(QB_ISSUERINFO, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeProvinceInfo
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_PROVINCEINFO, kDataTypeCharArray, Area_Code, "区域代码");
  ADDFIELD(QB_PROVINCEINFO, kDataTypeCharArray, Area_Name, "区域中文名称");
  ADDFIELD(QB_PROVINCEINFO, kDataTypeCharArray, Area_English_Name,
           "区域英文名称");
  ADDFIELD(QB_PROVINCEINFO, kDataTypeCharArray, Area_Level, "城市代码");
  ADDFIELD(QB_PROVINCEINFO, kDataTypeCharArray, Area_Upper_Grade_Code,
           "上一级");
  ADDFIELD(QB_PROVINCEINFO, kDataTypeChar, Flag, "");
  ADDFIELD(QB_PROVINCEINFO, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeSwsectorInfo
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_SWSECTORINFO, kDataTypeCharArray, SW_Internal_Code, "行业代码");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeChar, SW_Level, "行业level");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeCharArray, SW_Name, "行业中文名称");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeCharArray, SW_English_Name,
           "行业英文名称");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeCharArray, SW_Upper_Grade_Code,
           "上级行业代码");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeChar, Flag, "");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeSwsectorInfo2021
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_SWSECTORINFO, kDataTypeCharArray, SW_Internal_Code, "行业代码");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeChar, SW_Level, "行业level");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeCharArray, SW_Name, "行业中文名称");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeCharArray, SW_English_Name,
           "行业英文名称");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeCharArray, SW_Upper_Grade_Code,
           "上级行业代码");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeChar, Flag, "");
  ADDFIELD(QB_SWSECTORINFO, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeUnderwriter
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_UNDERWRITER, kDataTypeCharArray, UnderwriterUuid, "承销商id");
  ADDFIELD(QB_UNDERWRITER, kDataTypeCharArray, UnderwriterCode, "承销商code");
  ADDFIELD(QB_UNDERWRITER, kDataTypeCharArray, Short_Name_C, "中文简称");
  ADDFIELD(QB_UNDERWRITER, kDataTypeInt, Order, "排序");
  ADDFIELD(QB_UNDERWRITER, kDataTypeChar, Flag, "");
  ADDFIELD(QB_UNDERWRITER, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeFinancialCompany
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_FINANCIAL_COMPANY, kDataTypeCharArray, CompanyID, "机构ID");
  ADDFIELD(QB_FINANCIAL_COMPANY, kDataTypeCharArray, CompanyCode, "机构代码");
  ADDFIELD(QB_FINANCIAL_COMPANY, kDataTypeCharArray, Name, "简称");
  ADDFIELD(QB_FINANCIAL_COMPANY, kDataTypeCharArray, Full_Name, "全称");
  ADDFIELD(QB_FINANCIAL_COMPANY, kDataTypeCharArray, Name_En, "英文简称");
  ADDFIELD(QB_FINANCIAL_COMPANY, kDataTypeCharArray, Full_Name_En, "英文全称");
  ADDFIELD(QB_FINANCIAL_COMPANY, kDataTypeCharArray, City_Name, "城市");
  ADDFIELD(QB_FINANCIAL_COMPANY, kDataTypeChar, Flag, "");
  ADDFIELD(QB_FINANCIAL_COMPANY, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeContinuousContractInfo
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_CONTINUOUS_CONTRACT_INFO, kDataTypeCharArray, ID, "键值");
  ADDFIELD(QB_CONTINUOUS_CONTRACT_INFO, kDataTypeCharArray, TFCKey,
           "连续合约Key");
  ADDFIELD(QB_CONTINUOUS_CONTRACT_INFO, kDataTypeCharArray, TFCID,
           "连续合约代码");
  ADDFIELD(QB_CONTINUOUS_CONTRACT_INFO, kDataTypeCharArray, TFCName,
           "连续合约的名称");
  ADDFIELD(QB_CONTINUOUS_CONTRACT_INFO, kDataTypeCharArray, TFID,
           "连续合约对应的实际合约代码");
  ADDFIELD(QB_CONTINUOUS_CONTRACT_INFO, kDataTypeCharArray, TFCDate,
           "连续合约切换日期");
  ADDFIELD(QB_CONTINUOUS_CONTRACT_INFO, kDataTypeChar, Flag, "");
  ADDFIELD(QB_CONTINUOUS_CONTRACT_INFO, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeExchangeRepo
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_EXCHANGEREPO_INFO, kDataTypeCharArray, RateKey, "");
  ADDFIELD(QB_EXCHANGEREPO_INFO, kDataTypeCharArray, ID, "");
  ADDFIELD(QB_EXCHANGEREPO_INFO, kDataTypeCharArray, Code, "");
  ADDFIELD(QB_EXCHANGEREPO_INFO, kDataTypeCharArray, Name, "");
  ADDFIELD(QB_EXCHANGEREPO_INFO, kDataTypeCharArray, ListedMarket, "");
  ADDFIELD(QB_EXCHANGEREPO_INFO, kDataTypeChar, Flag, "");
  ADDFIELD(QB_EXCHANGEREPO_INFO, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeBondCDCAuth
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_BONDCDCAUTH, kDataTypeCharArray, BondKey, "BondKey");
  ADDFIELD(QB_BONDCDCAUTH, kDataTypeCharArray, BondID, "BondID");
  ADDFIELD(QB_BONDCDCAUTH, kDataTypeCharArray, BondProperty, "债券性质");
  ADDFIELD(QB_BONDCDCAUTH, kDataTypeCharArray, Custodian, "托管机构");
  ADDFIELD(QB_BONDCDCAUTH, kDataTypeCharArray, CDCAuth, "权限");
  ADDFIELD(QB_BONDCDCAUTH, kDataTypeChar, Flag, "");
  ADDFIELD(QB_BONDCDCAUTH, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeBondCRMClause
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_BONDCRM, kDataTypeCharArray, Bond_Key, "BondKey");
  ADDFIELD(QB_BONDCRM, kDataTypeCharArray, Reference_Code, "参考实体");
  ADDFIELD(QB_BONDCRM, kDataTypeCharArray, Settlement_Modes, "结算方式");
  ADDFIELD(QB_BONDCRM, kDataTypeCharArray, Settlement_ModesEn, "结算方式英文");
  ADDFIELD(QB_BONDCRM, kDataTypeCharArray, Registration_Date, "凭证登记日");
  ADDFIELD(QB_BONDCRM, kDataTypeDouble, First_Issue_Amount, "预配售额");
  ADDFIELD(QB_BONDCRM, kDataTypeCharArray, Creater_Code, "创设机构");
  ADDFIELD(QB_BONDCRM, kDataTypeCharArray, Refer_Bond_Id, "参考债券ShortName");
  ADDFIELD(QB_BONDCRM, kDataTypeCharArray, Refer_Bond_Key,
           "参考债券ComboBondKey");
  ADDFIELD(QB_BONDCRM, kDataTypeCharArray, Credit_Event, "信用事件");
  ADDFIELD(QB_BONDCRM, kDataTypeCharArray, Credit_EventEn, "信用事件英文");
  ADDFIELD(QB_BONDCRM, kDataTypeChar, Flag, "");
  ADDFIELD(QB_BONDCRM, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeABSBond
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_ABSBOND, kDataTypeCharArray, Bond_Key, "BondKey");
  ADDFIELD(QB_ABSBOND, kDataTypeCharArray, ABS_ID, "ABS_ID");
  ADDFIELD(QB_ABSBOND, kDataTypeCharArray, Tranche_Class, "产品结构");
  ADDFIELD(QB_ABSBOND, kDataTypeCharArray, Series_Name, "系列");
  ADDFIELD(QB_ABSBOND, kDataTypeCharArray, Issuer_Code, "发行人");
  ADDFIELD(QB_ABSBOND, kDataTypeCharArray, ABS_Type1, "ABS_Type1");
  ADDFIELD(QB_ABSBOND, kDataTypeCharArray, ABS_Type2, "ABS_Type2");
  ADDFIELD(QB_ABSBOND, kDataTypeCharArray, ABS_Type3, "ABS_Type3");
  ADDFIELD(QB_ABSBOND, kDataTypeCharArray, Actual_Financier, "实际融资人");
  ADDFIELD(QB_ABSBOND, kDataTypeCharArray, Credit_Subject, "信用主体");
  ADDFIELD(QB_ABSBOND, kDataTypeChar, Flag, "");
  ADDFIELD(QB_ABSBOND, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeMainUnderwriter
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(QB_MAIN_UNDERWRITER, kDataTypeCharArray, Institution_Code,
           "发行人代码");
  ADDFIELD(QB_MAIN_UNDERWRITER, kDataTypeCharArray, Full_Name_C,
           "发行机构全称");
  ADDFIELD(QB_MAIN_UNDERWRITER, kDataTypeCharArray, Short_Name_C, "中文简称");
  ADDFIELD(QB_MAIN_UNDERWRITER, kDataTypeCharArray, Full_Name_E, "英文全称");
  ADDFIELD(QB_MAIN_UNDERWRITER, kDataTypeCharArray, Short_Name_E, "英文简称");
  ADDFIELD(QB_MAIN_UNDERWRITER, kDataTypeChar, Flag, "");
  ADDFIELD(QB_MAIN_UNDERWRITER, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeBondConversion
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(BOND_CONVERSION, kDataTypeCharArray, ComBondKey, "债券组合键");
  ADDFIELD(BOND_CONVERSION, kDataTypeCharArray, ConversionRate,
           "质押比例 107.54");
  ADDFIELD(BOND_CONVERSION, kDataTypeChar, Flag, "");
  ADDFIELD(BOND_CONVERSION, kDataTypeInt, Sequence, "变更序列号");
  ADDKEYFIELD(BOND_CONVERSION, kDataTypeCharArray, Key.BondKey,
              "债券key B0000332012CORLEB01");
  ADDKEYFIELD(BOND_CONVERSION, kDataTypeCharArray, Key.ListedMarket,
              "市场代码 CIB/SSE/SZE");

  // kDictTypeBondDefaulted
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(BOND_DEFAULTED, kDataTypeCharArray, ComBondKey, "债券组合键");
  ADDFIELD(BOND_DEFAULTED, kDataTypeChar, Flag, "");
  ADDFIELD(BOND_DEFAULTED, kDataTypeInt, Sequence, "变更序列号");
  ADDKEYFIELD(BOND_DEFAULTED, kDataTypeCharArray, Key.BondKey,
              "债券key B0000332012CORLEB01");
  ADDKEYFIELD(BOND_DEFAULTED, kDataTypeCharArray, Key.ListedMarket,
              "市场代码 CIB/SSE/SZE");

  // kDictTypeBondKongfu
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(BOND_KONGFU, kDataTypeCharArray, ISIN_Code, "ISIN");
  ADDFIELD(BOND_KONGFU, kDataTypeCharArray, Short_Name_C, "债券名称");
  ADDFIELD(BOND_KONGFU, kDataTypeCharArray, Issuer_Name, "信用主体");
  ADDFIELD(BOND_KONGFU, kDataTypeCharArray, Maturity_Date, "到日期");
  ADDFIELD(BOND_KONGFU, kDataTypeCharArray, Interest_Accrual_Date, "起息日");
  ADDFIELD(BOND_KONGFU, kDataTypeCharArray, Outstanding_Amount, "未偿还债");
  ADDFIELD(BOND_KONGFU, kDataTypeCharArray, Issued_Amount, "发行额");
  ADDFIELD(BOND_KONGFU, kDataTypeCharArray, Next_Put_Date, "下一个回售日");
  ADDFIELD(BOND_KONGFU, kDataTypeCharArray, Next_Call_Date, "下一个赎回日");
  ADDFIELD(BOND_KONGFU, kDataTypeCharArray, Lowest_Rating, "最低债项评级");
  ADDFIELD(BOND_KONGFU, kDataTypeChar, Flag, "");
  ADDFIELD(BOND_KONGFU, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeSpecialLabelInfo
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(SPECAIL_LABEL_INFO, kDataTypeCharArray, id, "标签ID");
  ADDFIELD(SPECAIL_LABEL_INFO, kDataTypeCharArray, label,
           "标签名 偏/权/违/次等");
  ADDFIELD(SPECAIL_LABEL_INFO, kDataTypeCharArray, color,
           "标签颜色 #0xFF172422");
  ADDFIELD(SPECAIL_LABEL_INFO, kDataTypeInt, property, "属性 交易/债券/条款");
  ADDFIELD(SPECAIL_LABEL_INFO, kDataTypeCharArray, comments, "注释说明");
  ADDFIELD(SPECAIL_LABEL_INFO, kDataTypeInt, label_order, "标签排序");
  ADDFIELD(SPECAIL_LABEL_INFO, kDataTypeChar, Flag, "");
  ADDFIELD(SPECAIL_LABEL_INFO, kDataTypeInt, Sequence, "变更序列号");

  // kDictTypeBondSpecialLabel
  CHECK_ADD_DICTDESC(pdd);
  ADDFIELD(BOND_SPECIAL_LABEL, kDataTypeCharArray, bond_label, "债券组合键");
  // ADDFIELD(BOND_SPECIAL_LABEL, kDataTypeCharArray, label_id, "标签ID");
  ADDFIELD(BOND_SPECIAL_LABEL, kDataTypeCharArray, label_tip, "标签Tips");
  ADDFIELD(BOND_SPECIAL_LABEL, kDataTypeInt, label_order, "标签顺序");
  ADDFIELD(BOND_SPECIAL_LABEL, kDataTypeChar, Flag, "");
  ADDFIELD(BOND_SPECIAL_LABEL, kDataTypeInt, Sequence, "变更序列号");
  ADDKEYFIELD(BOND_SPECIAL_LABEL, kDataTypeCharArray, Key.bond_key,
              "债券key B0000332012CORLEB01.CIB");
  ADDKEYFIELD(BOND_SPECIAL_LABEL, kDataTypeCharArray, Key.label_id, "标签ID");

  CHECK_ADD_DICTDESC(pdd);
  BASSERT(pdd == dds + kDictTypeCount);

  // 从SSBondLoader::FinishUpdate中而来,将需要导出的列的字段名称抽取出来
  // kDictTypeMacroIndex导出比较特殊
  dds[kDictTypeBondList].SetExportFields(
      "ComBondKey,BondID,ShortName,BondSubType,Guarantee,TermToMaturity,"
      "ListDate,MaturityDate,OptionDate,IssuerRating,BondRating,"
      "InstitutionRating,RateType,Coupon_Type,MarketType,InterestStartDate,"
      "IsMortgage,IsCrossMarket,InstitutionSubtype,YieldCurveType,IsMunicipal,"
      "BondFullName,MaturityTerm,OptionType,Issuer_Code,FullNameEN,ShortNameEN,"
      "Outlook,Ent_Cor,Coupon_Frequency,Compound_Frequency,Planned_Exercise_"
      "Date,Next_Coupon_Date,conversion_rate,Issue_Rate,FRN_Index_ID,Fixing_MA_"
      "Days,Issuer_Rating_Institution_Code,Outstanding_Amount,Interest_Basis,"
      "IssuerRatingCBR,OutlookCBR,CDC_Implied_Rating,CSI_Implied_Rating,"
      "Currency,Warranter,bond_tag,pay_date,Sceniority,Category_flag");
  dds[kDictTypeBondPrimaryInfo].SetExportFields(
      "ComBondKey,PlannedIssueAmount,Actual_Issue_Amount,PaymentDate,"
      "CouponRateCurrent,AuctionDateStart,AuctionDateEnd,Auction_Date_Time,"
      "AnnounceDate,IssueStartDate,IssueEndDate,Issue_End_Time,Issue_Period,"
      "Underwriters,Bid_Limit_Bottom,Bid_Limit_Top,Auction_Flr,Auction_Cap,"
      "Auction_Step,Auction_Unit,MainUnderwriters,JointUnderwriters,"
      "BondFileNum,Auction_Type,Auction_Time_Start,Auction_Time_End,Issue_Type,"
      "Asset_Status,Type");
  dds[kDictTypeBondAdditionInfo].SetExportFields(
      "Add_Issue_Key,Add_Issue_ID,Add_Issue_Short_Name,Add_Full_Name,No_Add_"
      "Issue,First_Issue_Key,First_Issue_ID,Add_Announce_Date,Add_Auction_Date,"
      "Add_Issue_Start_Date,Add_Issue_End_Date,Add_Dist_Date_Start,Add_Dist_"
      "Date_End,Add_Payment_Date,Add_Listed_Date,Add_Issue_Commission_Rate,Add_"
      "Issue_Price,Add_Planned_Issue_Amount,Add_Issue_Amount,Mkt_Type,Ann_"
      "Status,Reason,Bid_Outcome,Auction_Type,Auction_Time_Start,Auction_Time_"
      "End");
  dds[kDictTypeBondOptionInfo].SetExportFields(
      "ComBondKey,CallStr,PutStr,OptionType");
  dds[kDictTypeBondAuctionInfo].SetExportFields(
      "Bond_Key,Auction_Time_Start,Auction_Time_End,Planed_Auction_Amount,"
      "Actual_Auction_Amount,WA_Tender_Rate,MG_Tender_Rate,Subscription_Ratio,"
      "Marginal_Ratio");
  dds[kDictTypeBondDict].SetExportFields(
      "Selective_Code,Group_Name,SortCode,Selective_Content,Selective_Content_"
      "EN");
  dds[kDictTypeBondHoliday].SetExportFields(
      "Country,Market,Holiday,Status,HolidayReason");
  dds[kDictTypeMacroIndex].SetExportFields("Code,Value,Date,EndDate");
  dds[kDictTypeIssuerInfo].SetExportFields(
      "Institution_Code,Full_Name_C,Issuer_Type,SW_Sector_Code,SW_Subsector_"
      "Code,SW_Sector_Code_2021,Province_Code,Short_Name_C,Full_Name_E,Short_"
      "Name_E,Listed_Type,Actual_Controller_Name,Actual_Controller_Type,Rate,"
      "CBRC_Financing_Platform,Municipal_code,Issuer_tag");
  dds[kDictTypeMainUnderwriter].SetExportFields(
      "Institution_Code,Full_Name_C,Short_Name_C,Full_Name_E,Short_Name_E");
  dds[kDictTypeProvinceInfo].SetExportFields(
      "Area_Code,Area_Name,Area_English_Name");
  dds[kDictTypeSwsectorInfo].SetExportFields(
      "SW_Internal_Code,SW_Level,SW_Name,SW_English_Name,SW_Upper_Grade_Code");
  dds[kDictTypeSwsectorInfo2021].SetExportFields(
      "SW_Internal_Code,SW_Level,SW_Name,SW_English_Name,SW_Upper_Grade_Code");
  dds[kDictTypeUnderwriter].SetExportFields(
      "UnderwriterCode,UnderwriterUuid,Short_Name_C,Order");
  dds[kDictTypeFinancialCompany].SetExportFields(
      "CompanyID,CompanyCode,Name,Full_Name,Name_En,Full_Name_En,City_Name");
  dds[kDictTypeContinuousContractInfo].SetExportFields(
      "ID,TFCKey,TFCID,TFCName,TFID,TFCDate");
  dds[kDictTypeExchangeRepo].SetExportFields(
      "RateKey,ListedMarket,ID,Code,Name");
  dds[kDictTypeBondCDCAuth].SetExportFields(
      "BondKey,BondID,BondProperty,Custodian,CDCAuth");
  dds[kDictTypeBondCRMClause].SetExportFields(
      "Bond_Key,Reference_Code,Settlement_Modes,Settlement_ModesEn,"
      "Registration_Date,First_Issue_Amount,Creater_Code,Refer_Bond_Key,Refer_"
      "Bond_Id,Credit_Event,Credit_EventEn");
  dds[kDictTypeABSBond].SetExportFields(
      "Bond_Key,ABS_ID,Tranche_Class,Series_Name,Issuer_Code,ABS_Type1,ABS_"
      "Type2,ABS_Type3,Actual_Financier,Credit_Subject");
  dds[kDictTypeBondConversion].SetExportFields("ComBondKey,ConversionRate");
  dds[kDictTypeBondDefaulted].SetExportFields("ComBondKey");
  dds[kDictTypeBondKongfu].SetExportFields(
      "ISIN_Code,Short_Name_C,Issuer_Name,Maturity_Date,Interest_Accrual_Date,"
      "Outstanding_Amount,Issued_Amount,Next_Put_Date,Next_Call_Date,Lowest_"
      "Rating");
  dds[kDictTypeSpecialLabelInfo].SetExportFields(
      "id,label,color,property,comments,label_order");
  dds[kDictTypeBondSpecialLabel].SetExportFields(
      "bond_label,label_tip,label_order");

  dds[kDictTypeMacroIndex].SetDoublePrecision(6);
#ifdef USING_CONFIGVM
  if (BOOLTEST(kProfileDictEncrypt)) {
    dds[kDictTypeFinancialCompany].SetTag("ss.qb.dictkey");
    BLOGWARN("字典FinancialCompany启用加密");
  }
#endif

  // 设置文件参数信息,先使用内部默认参数,后使用配置参数
  // 此参数更改会导致丢弃原先数据,重新拉全量
  std::string params =
      "BondList.fmap,4,8;BondPrimaryInfo.fmap,2,4;BondAdditionInfo.fmap,1,1;"
      "BondDict.fmap,1,1;Holiday.fmap,1,1;MacroIndex.fmap,2,4;IssuerInfo.fmap,"
      "1,1;ProvinceInfo.fmap,1,1;SwSectorInfo.fmap,1,1;SwSectorInfo2021.fmap,1,"
      "1;Underwriter.fmap,1,1;SSData0.fmap,1,1;ContinCInfo.fmap,1,1;"
      "ExchangeRepo.fmap,1,1;BondCDCAuth.fmap,1,1";
  SetDictParams(dds, kDictTypeCount, params.c_str());
#ifdef USING_CONFIGVM
  SetDictParams(dds, kDictTypeCount,
                AfxGetConfig().GetString(kProfileDictParams));
#endif
  initialized = true;
  return dds[index];
}
}  // namespace ht
}  // namespace qb
